home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / appsrcs.zip / APPSETUP.ZIP / APPSOUND.C < prev    next >
C/C++ Source or Header  |  1993-02-08  |  9KB  |  290 lines

  1. #define STRICT
  2. #include <windows.h>
  3. #include <windowsx.h>
  4. #include <mmsystem.h>
  5. #include <string.h>
  6. #include "appsetup.h"
  7.  
  8. int nSoundFocus = 0;
  9.  
  10. /*-------------------------------------------------------------------------*/
  11. BOOL WINAPI SoundDlgProc(HWND hDlgSound, UINT message, WPARAM wParam, LPARAM lParam)
  12.     {
  13.     static DLGPROC lpfnSelectDirDlgProc;
  14.  
  15.     switch(message)
  16.     {
  17.     case WM_INITDIALOG:
  18.         AppSoundNew = AppSound;
  19.         CheckDlgButton(hDlgSound, IDSOUND_ENABLE, AppSoundNew.EnableSound);
  20.         SetDlgItemText(hDlgSound, IDSOUND_APPSTART, AppSoundNew.AppBarStart);
  21.         SetDlgItemText(hDlgSound, IDSOUND_APPEXIT, AppSoundNew.AppBarExit);
  22.         SetDlgItemText(hDlgSound, IDSOUND_WINEXIT, AppSoundNew.WindowsExit);
  23.         SetDlgItemText(hDlgSound, IDSOUND_PROGSTART, AppSoundNew.ProgramStart);
  24.         SetDlgItemText(hDlgSound, IDSOUND_PROGCLOSE, AppSoundNew.ProgramClose);
  25.         SetDlgItemText(hDlgSound, IDSOUND_DROPFILE, AppSoundNew.DropFile);
  26.         SetDlgItemText(hDlgSound, IDSOUND_ERROR, AppSoundNew.ErrorMessage);
  27.         SetDlgItemText(hDlgSound, IDSOUND_SOUNDDIR, AppSoundNew.SoundDirectory);
  28.         return TRUE;
  29.  
  30.     case WM_COMMAND:
  31.         switch(wParam)
  32.         {
  33.         case IDSOUND_APPSTART:
  34.             nSoundFocus = 0;
  35.             if(HIWORD(lParam) == EN_KILLFOCUS)
  36.             {
  37.             GetDlgItemText(hDlgSound, IDSOUND_APPSTART, AppSoundNew.AppBarStart, MAXFILECHARS-1);
  38.             SetDlgItemText(hDlgSound, IDSOUND_APPSTART, AppSoundNew.AppBarStart);
  39.             }
  40.             return TRUE;
  41.  
  42.         case IDSOUND_APPEXIT:
  43.             nSoundFocus = 1;
  44.             if(HIWORD(lParam) == EN_KILLFOCUS)
  45.             {
  46.             GetDlgItemText(hDlgSound, IDSOUND_APPEXIT, AppSoundNew.AppBarExit, MAXFILECHARS-1);
  47.             SetDlgItemText(hDlgSound, IDSOUND_APPEXIT, AppSoundNew.AppBarExit);
  48.             }
  49.             return TRUE;
  50.  
  51.         case IDSOUND_WINEXIT:
  52.             nSoundFocus = 2;
  53.             if(HIWORD(lParam) == EN_KILLFOCUS)
  54.             {
  55.             GetDlgItemText(hDlgSound, IDSOUND_WINEXIT, AppSoundNew.WindowsExit, MAXFILECHARS-1);
  56.             SetDlgItemText(hDlgSound, IDSOUND_WINEXIT, AppSoundNew.WindowsExit);
  57.             }
  58.             return TRUE;
  59.  
  60.         case IDSOUND_PROGSTART:
  61.             nSoundFocus = 3;
  62.             if(HIWORD(lParam) == EN_KILLFOCUS)
  63.             {
  64.             GetDlgItemText(hDlgSound, IDSOUND_PROGSTART, AppSoundNew.ProgramStart, MAXFILECHARS-1);
  65.             SetDlgItemText(hDlgSound, IDSOUND_PROGSTART, AppSoundNew.ProgramStart);
  66.             }
  67.             return TRUE;
  68.  
  69.         case IDSOUND_PROGCLOSE:
  70.             nSoundFocus = 4;
  71.             if(HIWORD(lParam) == EN_KILLFOCUS)
  72.             {
  73.             GetDlgItemText(hDlgSound, IDSOUND_PROGCLOSE, AppSoundNew.ProgramClose, MAXFILECHARS-1);
  74.             SetDlgItemText(hDlgSound, IDSOUND_PROGCLOSE, AppSoundNew.ProgramClose);
  75.             }
  76.             return TRUE;
  77.  
  78.         case IDSOUND_DROPFILE:
  79.             nSoundFocus = 5;
  80.             if(HIWORD(lParam) == EN_KILLFOCUS)
  81.             {
  82.             GetDlgItemText(hDlgSound, IDSOUND_DROPFILE, AppSoundNew.DropFile, MAXFILECHARS-1);
  83.             SetDlgItemText(hDlgSound, IDSOUND_DROPFILE, AppSoundNew.DropFile);
  84.             }
  85.             return TRUE;
  86.  
  87.         case IDSOUND_ERROR:
  88.             nSoundFocus = 6;
  89.             if(HIWORD(lParam) == EN_KILLFOCUS)
  90.             {
  91.             GetDlgItemText(hDlgSound, IDSOUND_ERROR, AppSoundNew.ErrorMessage, MAXFILECHARS-1);
  92.             SetDlgItemText(hDlgSound, IDSOUND_ERROR, AppSoundNew.ErrorMessage);
  93.             }
  94.             return TRUE;
  95.  
  96.         case IDSOUND_SOUNDDIR:
  97.             nSoundFocus = 7;
  98.             if(HIWORD(lParam) == EN_KILLFOCUS)
  99.             {
  100.             GetDlgItemText(hDlgSound, IDSOUND_SOUNDDIR, AppSoundNew.SoundDirectory, MAXFILECHARS-1);
  101.             SetDlgItemText(hDlgSound, IDSOUND_SOUNDDIR, AppSoundNew.SoundDirectory);
  102.             }
  103.             return TRUE;
  104.  
  105.         case IDSOUND_BROWSE:
  106.             switch(nSoundFocus)
  107.             {
  108.             case 0:
  109.                 if(BrowseFile(szBuffer, hDlgSound, WAVEFILES))
  110.                 {
  111.                 strcpy(AppSoundNew.AppBarStart, szBuffer);
  112.                 SetDlgItemText(hDlgSound, IDSOUND_APPSTART, AppSoundNew.AppBarStart);
  113.                 }
  114.                 break;
  115.  
  116.             case 1:
  117.                 if(BrowseFile(szBuffer, hDlgSound, WAVEFILES))
  118.                 {
  119.                 strcpy(AppSoundNew.AppBarExit, szBuffer);
  120.                 SetDlgItemText(hDlgSound, IDSOUND_APPEXIT, AppSoundNew.AppBarExit);
  121.                 }
  122.                 break;
  123.  
  124.             case 2:
  125.                 if(BrowseFile(szBuffer, hDlgSound, WAVEFILES))
  126.                 {
  127.                 strcpy(AppSoundNew.WindowsExit, szBuffer);
  128.                 SetDlgItemText(hDlgSound, IDSOUND_WINEXIT, AppSoundNew.WindowsExit);
  129.                 }
  130.                 break;
  131.  
  132.             case 3:
  133.                 if(BrowseFile(szBuffer, hDlgSound, WAVEFILES))
  134.                 {
  135.                 strcpy(AppSoundNew.ProgramStart, szBuffer);
  136.                 SetDlgItemText(hDlgSound, IDSOUND_PROGSTART, AppSoundNew.ProgramStart);
  137.                 }
  138.                 break;
  139.  
  140.             case 4:
  141.                 if(BrowseFile(szBuffer, hDlgSound, WAVEFILES))
  142.                 {
  143.                 strcpy(AppSoundNew.ProgramClose, szBuffer);
  144.                 SetDlgItemText(hDlgSound, IDSOUND_PROGCLOSE, AppSoundNew.ProgramClose);
  145.                 }
  146.                 break;
  147.  
  148.             case 5:
  149.                 if(BrowseFile(szBuffer, hDlgSound, WAVEFILES))
  150.                 {
  151.                 strcpy(AppSoundNew.DropFile, szBuffer);
  152.                 SetDlgItemText(hDlgSound, IDSOUND_DROPFILE, AppSoundNew.DropFile);
  153.                 }
  154.                 break;
  155.  
  156.             case 6:
  157.                 if(BrowseFile(szBuffer, hDlgSound, WAVEFILES))
  158.                 {
  159.                 strcpy(AppSoundNew.ErrorMessage, szBuffer);
  160.                 SetDlgItemText(hDlgSound, IDSOUND_ERROR, AppSoundNew.ErrorMessage);
  161.                 }
  162.                 break;
  163.  
  164.             case 7:
  165.                 lpfnSelectDirDlgProc = (DLGPROC) MakeProcInstance(SelectDirDlgProc, hInst);
  166.                 DialogBox(hInst, "SelectDirDlg", hDlgSound, lpfnSelectDirDlgProc);
  167.                 FreeProcInstance((FARPROC) lpfnSelectDirDlgProc);
  168.                 InvalidateRect(hDlgSound, NULL, TRUE);
  169.                 UpdateWindow(hDlgSound);
  170.                 if(bNewDir)
  171.                 {
  172.                 strcpy(AppSound.SoundDirectory, Directory);
  173.                 SetDlgItemText(hDlgSound, IDSOUND_SOUNDDIR, AppSound.SoundDirectory);
  174.                 bNewDir = FALSE;
  175.                 }
  176.                 break;
  177.  
  178.             }
  179.             return TRUE;
  180.  
  181.         case IDSOUND_TEST:
  182.             switch(nSoundFocus)
  183.             {
  184.             case 0:
  185.                 SendDlgItemMessage(hDlgSound, IDSOUND_APPSTART, EM_SETSEL, 0, MAKELONG(0, -1));
  186.                 if(stricmp(AppSoundNew.AppBarStart, "<none>") != 0)
  187.                 sndPlaySound(AppSoundNew.AppBarStart, SND_ASYNC | SND_NODEFAULT);
  188.                 break;
  189.  
  190.             case 1:
  191.                 SendDlgItemMessage(hDlgSound, IDSOUND_APPEXIT, EM_SETSEL, 0, MAKELONG(0, -1));
  192.                 if(stricmp(AppSoundNew.AppBarExit, "<none>") != 0)
  193.                 sndPlaySound(AppSoundNew.AppBarExit, SND_ASYNC | SND_NODEFAULT);
  194.                 break;
  195.  
  196.             case 2:
  197.                 SendDlgItemMessage(hDlgSound, IDSOUND_WINEXIT, EM_SETSEL, 0, MAKELONG(0, -1));
  198.                 if(stricmp(AppSoundNew.WindowsExit, "<none>") != 0)
  199.                 sndPlaySound(AppSoundNew.WindowsExit, SND_ASYNC | SND_NODEFAULT);
  200.                 break;
  201.  
  202.             case 3:
  203.                 SendDlgItemMessage(hDlgSound, IDSOUND_PROGSTART, EM_SETSEL, 0, MAKELONG(0, -1));
  204.                 if(stricmp(AppSoundNew.ProgramStart, "<none>") != 0)
  205.                 sndPlaySound(AppSoundNew.ProgramStart, SND_ASYNC | SND_NODEFAULT);
  206.                 break;
  207.  
  208.             case 4:
  209.                 SendDlgItemMessage(hDlgSound, IDSOUND_PROGCLOSE, EM_SETSEL, 0, MAKELONG(0, -1));
  210.                 if(stricmp(AppSoundNew.ProgramClose, "<none>") != 0)
  211.                 sndPlaySound(AppSoundNew.ProgramClose, SND_ASYNC | SND_NODEFAULT);
  212.                 break;
  213.  
  214.             case 5:
  215.                 SendDlgItemMessage(hDlgSound, IDSOUND_DROPFILE, EM_SETSEL, 0, MAKELONG(0, -1));
  216.                 if(stricmp(AppSoundNew.DropFile, "<none>") != 0)
  217.                 sndPlaySound(AppSoundNew.DropFile, SND_ASYNC | SND_NODEFAULT);
  218.                 break;
  219.  
  220.             case 6:
  221.                 SendDlgItemMessage(hDlgSound, IDSOUND_ERROR, EM_SETSEL, 0, MAKELONG(0, -1));
  222.                 if(stricmp(AppSoundNew.ErrorMessage, "<none>") != 0)
  223.                 sndPlaySound(AppSoundNew.ErrorMessage, SND_ASYNC | SND_NODEFAULT);
  224.                 break;
  225.             }
  226.             return TRUE;
  227.  
  228.         case IDSOUND_NONE:
  229.             switch(nSoundFocus)
  230.             {
  231.             case 0:
  232.                 strcpy(AppSoundNew.AppBarStart, "<none>");
  233.                 SetDlgItemText(hDlgSound, IDSOUND_APPSTART, AppSoundNew.AppBarStart);
  234.                 break;
  235.  
  236.             case 1:
  237.                 strcpy(AppSoundNew.AppBarExit, "<none>");
  238.                 SetDlgItemText(hDlgSound, IDSOUND_APPEXIT, AppSoundNew.AppBarExit);
  239.                 break;
  240.  
  241.             case 2:
  242.                 strcpy(AppSoundNew.WindowsExit, "<none>");
  243.                 SetDlgItemText(hDlgSound, IDSOUND_WINEXIT, AppSoundNew.WindowsExit);
  244.                 break;
  245.  
  246.             case 3:
  247.                 strcpy(AppSoundNew.ProgramStart, "<none>");
  248.                 SetDlgItemText(hDlgSound, IDSOUND_PROGSTART, AppSoundNew.ProgramStart);
  249.                 break;
  250.  
  251.             case 4:
  252.                 strcpy(AppSoundNew.ProgramClose, "<none>");
  253.                 SetDlgItemText(hDlgSound, IDSOUND_PROGCLOSE, AppSoundNew.ProgramClose);
  254.                 break;
  255.  
  256.             case 5:
  257.                 strcpy(AppSoundNew.DropFile, "<none>");
  258.                 SetDlgItemText(hDlgSound, IDSOUND_DROPFILE, AppSoundNew.DropFile);
  259.                 break;
  260.  
  261.             case 6:
  262.                 strcpy(AppSoundNew.ErrorMessage, "<none>");
  263.                 SetDlgItemText(hDlgSound, IDSOUND_ERROR, AppSoundNew.ErrorMessage);
  264.                 break;
  265.             }
  266.             return TRUE;
  267.  
  268.         case IDSOUND_HELP:
  269.             WinHelp(hWnd, "AppSetup.hlp",HELP_CONTENTS, 0L);
  270.             return TRUE;
  271.  
  272.         case IDSOUND_OK:
  273.             bSave = TRUE;
  274.             if(IsDlgButtonChecked(hDlgSound, IDSOUND_ENABLE))
  275.             AppSoundNew.EnableSound = 1;
  276.             else
  277.             AppSoundNew.EnableSound = 0;
  278.             AppSound = AppSoundNew;
  279.             EndDialog(hDlgSound, 0);
  280.             return TRUE;
  281.  
  282.         case IDSOUND_CANCEL:
  283.             EndDialog(hDlgSound, 0);
  284.             return TRUE;
  285.         }
  286.         break;
  287.     }
  288.     return FALSE;
  289.     }
  290.